package com.jxust.mapper;

import com.jxust.pojo.Clazz;
import com.jxust.pojo.ClazzQueryParam;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ClazzMapper {

    List<Clazz> list(ClazzQueryParam clazzQueryParam);

    @Select("SELECT COUNT(*) FROM student WHERE clazz_id = #{clazzId}")
    int countStudentsByClazzId(@Param("clazzId") Integer clazzId);

    @Delete("DELETE FROM clazz WHERE id = #{id}")
    int deleteById(Integer id);

    @Insert("INSERT INTO clazz (name, room, begin_date, end_date, master_id, subject, create_time, update_time) " +
            "VALUES (#{name}, #{room}, #{beginDate}, #{endDate}, #{masterId}, #{subject}, #{createTime}, #{updateTime})")
    void insert(Clazz clazz);


    void update(Clazz clazz);
}
